package com.shuwen.gcdj.controller.Message;

import com.shuwen.gcdj.bean.conditionMonitoring.response.IndexAlarmMessageResp;
import com.shuwen.gcdj.bean.message.request.AlarmmessageQueryReq;
import com.shuwen.gcdj.bean.message.request.OrderMessageQueryReq;
import com.shuwen.gcdj.bean.message.request.PLCAlarmMessageManageQueryReq;
import com.shuwen.gcdj.bean.message.response.AlarmMessageResp;
import com.shuwen.gcdj.bean.message.response.OrderMessageResp;
import com.shuwen.gcdj.bean.message.response.PLCAlarmMessageResp;
import com.shuwen.gcdj.common.annotation.JWTAuth;
import com.shuwen.gcdj.common.api.CommonPage;
import com.shuwen.gcdj.common.api.CommonResult;
import com.shuwen.gcdj.service.message.MessageCenterService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/***
 ** Created YangX
 ** Date:2023/5/10
 */
@Api(tags = "消息中心")
@RestController
@RequestMapping("/messageCenter")
@Slf4j
public class MessageCenterController {
    @Autowired
    private MessageCenterService messageCenterService;

    @ApiOperation(value = "查询状态监测预警-分页")
    @PostMapping(value = "/getAlarmMessagePage")
    @JWTAuth
    public CommonResult<CommonPage<AlarmMessageResp>> getAlarmMessagePage(@RequestBody AlarmmessageQueryReq req) {

        return messageCenterService.getAlarmMessagePage(req);
    }

    @ApiOperation(value = "查询工单消息-分页")
    @PostMapping(value = "/getOrderMessagePage")
    @JWTAuth
    public CommonResult<CommonPage<OrderMessageResp>> getOrderMessagePage(@RequestBody OrderMessageQueryReq req) {
        return messageCenterService.getOrderMessagePage(req);
    }

    @ApiOperation(value = "查询PLC报警-分页")
    @PostMapping(value = "/getPLCAlarmMessagePage")
    @JWTAuth
    public CommonResult<CommonPage<PLCAlarmMessageResp>> getPLCAlarmMessagePage(@RequestBody PLCAlarmMessageManageQueryReq req) {
        return messageCenterService.getPLCAlarmMessagePage(req);
    }

    @ApiOperation(value = "首页预警信息查询")
    @GetMapping(value = "/getIndexAlarmMessageList/{equipmentId}")
    @JWTAuth
    public CommonResult<List<IndexAlarmMessageResp>> getIndexAlarmMessageList(@PathVariable String equipmentId) {
        return messageCenterService.getIndexAlarmMessageList(equipmentId);
    }

    @ApiOperation(value = "添加plc报警信息")
    @PostMapping(value = "/addPlcAlarmJob")
    @JWTAuth
    public CommonResult<Integer> addPlcAlarmJob() {
        return messageCenterService.addPlcAlarmJob();
    }
}
